/**
 * 38. 外观数列
 */
public class NumList {

    public static String getNumList(int n){
        String str="1";
        for(int i=2;i<=n;++i){
            StringBuilder builder=new StringBuilder();
            int j=0;
            int start=0;
            while (j<str.length()){
                while (j<str.length()&&str.charAt(j)==str.charAt(start)){
                    j++;
                }
                builder.append(j-start).append(str.charAt(start));
                start=j;
            }
            str=builder.toString();
        }
        return str;
    }

    public static void main(String[] args) {
        System.out.println(getNumList(4));
    }
}
